|2010 PASSWORD$="|36":BLINKNORMAL%=|28:BLINKINSERT%=|29:BLINK2%=|30 'For CGA or EGA adapter, BLINKNORMAL%=6, BLINKINSERT%=4 and BLINK2%=7. For Monochrome adapter, BLINKNORMAL%=13, BLINKINSERT%=9 and BLINK2%=14.
|2020 LOCATE 1,10:COLOR COLA%(2),COLB%(1):PRINT "Program |01 To Create The Blank |11 Data Base Files";:COLOR 7,0:PASSCOUNT%=0
2120 CLS:PRINT "Data Files for the ";ZB$;" Data Base":PRINT:FOR J = 1 TO ZQ:PRINT J;" - ";ZS$(J,1):PRINT:NEXT:PRINT:INPUT "Enter file number to Blank (A=All)";ANS$
2130 IF ANS$ = "A" OR ANS$ = "a" THEN ZSTART = 1:ZEND=ZQ:GOTO 2180 ELSE ZSTART = VAL(ANS$):ZEND = ZSTART:GOTO 2150
2140 IF VAL(ANS$) = 0 OR VAL(ANS$) > ZQ THEN GOTO 460 'Pressed Enter, zero or too large a number
2150 IF ZS%(ZSTART,1) = 1 THEN GOTO 2180 ELSE FOR J=1 TO ZQ:IF ZS$(J,1) = ZS$(ZSTART,2) THEN MASTER = J:J=ZQ
2160 NEXT:FOR J=2 TO ZS%(MASTER,4)+1:IF ZS$(ZSTART,1) = ZS$(MASTER,J) THEN DETAIL = J-1:J=ZS%(MASTER,4)+1
2170 NEXT
2180 DT$=LEFT$(DATE$,2)+MID$(DATE$,4,2)+LEFT$(DATE$,1):TM$=LEFT$(TIME$,5):ZERO=0 'Date and Time
2190 FOR FILENUM% = ZSTART TO ZEND 'Loop for each data file in the Data Base
2200 FORWARDPOINTER% = 1
2210 FOR K = 1 TO ZS%(FILENUM%,5) 'Number of file sections for each data file
2220 F$=CHR$(64+ZT%(FILENUM%,K,3))+":"+ZS$(FILENUM%,1) 'Drive Letter+:+File Name
2260 IF ZS%(FILENUM%,1)=2 THEN FIELD #1, 5 AS ZB$, 5 AS ZF$:RSET ZB$=STR$(0):RSET ZF$=STR$(0):C1=10:GOTO 2320 'Detail File
2270 FIELD #1, 5 AS ZC$, 5 AS ZP$, 5 AS ZN$:C1=15
2280 IF ZS%(FILENUM%,4) = 0 GOTO 2320
2290 FOR L = 1 TO ZS%(FILENUM%,4)
2300 FIELD #1, C1 AS DUMMY$, 5 AS ZH$(FILENUM%,L), 5 AS ZE$(FILENUM%,L):C1=C1+10:RSET ZH$(FILENUM%,L)=STR$(0):RSET ZE$(FILENUM%,L)=STR$(0)
2310 NEXT 'L
2320 C2=0:C3=0:C4=0
2330 FOR L=1 TO ZS%(FILENUM%,7) 'Number of fields in the file
2340 Y=ZSIZE%(FILENUM%,L) 'Length of each field
2350 FIELD #1, C1 AS DUMMY1$, C2 AS DUMMY2$, C3 AS DUMMY3$, C4 AS DUMMY$, Y AS Y$(L,FILENUM%):LSET Y$(L,FILENUM%)=STRING$(Y,32)
2360 IF C1+Y<256 THEN C1=C1+Y ELSE IF C2+Y<256 THEN C2=C2+Y ELSE IF C3+Y<256 THEN C3=C3+Y ELSE C4=C4+Y
2370 NEXT 'L
2380 IF ZS%(FILENUM%,1)=1 THEN RSET ZC$=STR$(0):RSET ZP$=STR$(0):RSET ZN$=STR$(0):FOR L=1 TO ZS%(FILENUM%,4):RSET ZH$(FILENUM%,L)=STR$(0):RSET ZE$(FILENUM%,L)=STR$(0):NEXT 'L
2390 ' House keeping fields
2400 FIELD #1, 5 AS HOUSE1$, 5 AS HOUSE2$, 5 AS HOUSE3$
2410 M = ZT%(FILENUM%,K,2) - ZT%(FILENUM%,K,1) + 1
2420 FOR L = 1 TO M
2430 IF ZS%(FILENUM%,1)=2 THEN FORWARDPOINTER%=FORWARDPOINTER%+1:RSET ZF$=STR$(FORWARDPOINTER%)
2440 PUT #1,L
2450 LOCATE 14,24,0:PRINT L;
2460 NEXT 'L
2470 IF K <> ZS%(FILENUM%,5) GOTO 2520
2480 'PUT the housekeeping record
2490 IF ZS%(FILENUM%,1)=1 THEN RSET HOUSE1$=STR$(0):LSET HOUSE2$=DT$:LSET HOUSE3$=TM$
2500 IF ZS%(FILENUM%,1)=2 THEN RSET HOUSE1$=STR$(0):RSET HOUSE2$=STR$(1):RSET HOUSE3$=STR$(0)
5640 IF YC%=75 THEN ZJ=ZJ-1:IF ZJ>0 THEN ZJ=ZJ-1:LOCATE ,POS(0)-1:RETURN 'left arrow
5650 IF YC%=77 AND ZJ<Z2 THEN LOCATE ,POS(0)+1:RETURN 'right arrow
5710 IF YC%=82 THEN ZJ=ZJ-1:IF INSERT%=0 AND ZJ<Z2 THEN INSERT%=1:LOCATE ,,,BLINKINSERT%,BLINK2%:RETURN ELSE INSERT%=0:LOCATE ,,,BLINKNORMAL%,BLINK2%:RETURN ' insert key
5720 IF YC%=83 THEN IF ZJ<Z2 THEN FLD$=MID$(F$,ZJ+1)+" " ELSE FLD$=" " 'delete key
5730 IF YC%=83 THEN COLOR 0,COLA%(3):LOCATE ,,0:PRINT FLD$:COLOR 7,0:LOCATE FLDPOSVERT%,POSY%,1:MID$(F$,ZJ)=FLD$:ZJ=ZJ-1:RETURN 'delete key
5740 SOUND 400,1:RETURN 'key not used
5800 'Character type field
5810 IF YC%>96 AND YC%<123 THEN YC%=YC%-32:YC$=CHR$(YC%):RETURN ELSE IF YC%>44 OR YC%<91 THEN RETURN
7000 'SUBROUTINE to set Chain Head and Chain End pointers to zero for Master file where an associated detail file was blanked
7010 FOR K = 1 TO ZS%(MASTER,5) 'Number of file sections for each data file
7020 F$=CHR$(64+ZT%(MASTER,K,3))+":"+ZS$(MASTER,1) 'Drive Letter+:+File Name
7030 LOCATE 12,17,1 : PRINT "Updating pointers in the '";F$;"' FILE. " ;:LOCATE 14,17,0:PRINT "Record";:PRINT SPC(25);
7040 OPEN F$ AS #1 LEN=ZS%(MASTER,3)
7050 C1=0
7070 FIELD #1, 5 AS ZC$, 5 AS ZP$, 5 AS ZN$:C1=15
7090 FOR L = 1 TO ZS%(MASTER,4) 'Detail Chain Head and Chain End pointers
7100 FIELD #1, C1 AS DUMMY$, 5 AS ZH$(MASTER,L), 5 AS ZE$(MASTER,L):C1=C1+10:LSET ZH$(MASTER,L)=STR$(0):LSET ZE$(MASTER,L)=STR$(0)
7110 NEXT 'L
7120 C2=0:C3=0:C4=0
7130 FOR L=1 TO ZS%(MASTER,7) 'Number of fields in the file
7140 Y=ZSIZE%(MASTER,L) 'Length of each field
7150 FIELD #1, C1 AS DUMMY1$, C2 AS DUMMY2$, C3 AS DUMMY3$, C4 AS DUMMY$, Y AS Y$(L,MASTER):LSET Y$(L,MASTER)=STRING$(Y,32)
7160 IF C1+Y<256 THEN C1=C1+Y ELSE IF C2+Y<256 THEN C2=C2+Y ELSE IF C3+Y<256 THEN C3=C3+Y ELSE C4=C4+Y
7170 NEXT 'L
7190 ' House keeping fields
7200 FIELD #1, 5 AS HOUSE1$, 5 AS HOUSE2$, 5 AS HOUSE3$
7210 M = ZT%(MASTER,K,2) - ZT%(MASTER,K,1) + 1
7220 FOR L = 1 TO M
7230 GET #1,L:RSET ZH$(MASTER,DETAIL) = STR$(0):RSET ZE$(MASTER,DETAIL) = STR$(0) 'GET the record and zero out just the Chain Head and End pointers for the proper Detail file